    var app = new Vue({
      el: "#app",
      data: {
        trainList: [],
        showLoad:false,
        loadMsg:"",
      },
      methods: {
        loadTrian() {
          var that = this;
          that.showLoad = true;
          axios({
            method: "get",
            url: "http://localhost:3000/selectTrian?train_date=2022-01-28&from_station=NKH&to_station=JKU",
          }).then(function (response) {
            that.showLoad = false;
            that.trainList = response.data;
            that.loadTrianInfo(0, that.trainList.length, that.trainList[0]);
          });
        },
        loadTrianInfo(j, length, item) {
          var id = item.train_id;
          var that = this;
          let from_station_name = item.from_station_name;
          that.showLoad = true;
          axios({
            method: "get",
            url:
              "http://localhost:3000/selectTrianInfo?train_no=" +
              id +
              "&from_station_telecode=NKH&to_station_telecode=JKU&depart_date=2022-01-28",
          }).then(function (response) {
            that.showLoad = false;
            // that.trainList[j].children = response.data;
            let PrevList = [];
            response.data.data.forEach((element,index) => {
                if(element.station_name === from_station_name){
                    PrevList.push(response.data.data[index-1])
                    PrevList.push(element); 
                }
            });
            Vue.set(that.trainList[j], "children", response.data.data);
            Vue.set(that.trainList[j], "PrevList", PrevList);
            if (++j < length) {
              that.loadTrianInfo(j, length, that.trainList[j]);
            }else{
                that.initSelectTrain();
            }
          });
        },
        initSelectTrain(){
            var that = this;
            this.trainList.forEach( async (element,index) => {
               let goList = await that.selectTrain(element.PrevList[0],element.PrevList[1],'2022-01-28')
               let backList = await that.selectTrain(element.PrevList[1],element.PrevList[0],'2022-01-28')
               goList = goList.filter(item=>{
                    return that.CompareDate(item.start_time,element.start_time) && that.CompareDate('07:30',item.start_time)
                })
                backList =backList.filter(item=>{
                    return that.CompareDate(item.start_time,element.start_time) && that.CompareDate('07:30',item.start_time)
                })

                Vue.set(that.trainList[index], "goList", goList);
                Vue.set(that.trainList[index], "backList", backList);
            });
            
        },
        selectTrain(from_station_list,to_station_list,train_date){
            var that  = this;
            that.showLoad = true;
            let from_station = array[from_station_list.station_name];
            let to_station  = array[to_station_list.station_name];
            that.loadMsg = '加载'+from_station_list.station_name+'到'+to_station_list.station_name+'的信息';
            var url = "http://localhost:3000/selectTrian?train_date="+train_date+"&from_station="+from_station+"&to_station="+to_station;
            var list  =axios.get(url).then(response=>{that.showLoad = false;that.loadMsg='';return response.data;}).catch(error => error)
            
            return list;
        },
        CompareDate (t1,t2) {
            var date = new Date();
            var a = t1.split(":");
            var b = t2.split(":");
            return date.setHours(a[0],a[1]) < date.setHours(b[0],b[1]);
        },
      },
      mounted() {
        this.loadTrian();
      },
    });